<template>
  <view>
    <view class="w100 pt-20 pl-24 pr-24">
      <view class="w100 h-154 br-10 rowsb rowsm pl-30 pr-30 mb-20" style="background-color: #F7F6FA;" v-for="(item,index2) in list" :key="index2" @click="goNext(item)" :style="item.isMax ? 'border: 2rpx solid crimson;' : ''">
        <view class="rowscl">
          <view class="fs-28 col333 fw-b mb-20" v-if="item.name">{{item.name}}</view>
          <view class="fs-28 col333 fw-b mb-20" v-else>{{index == 1 ? '基础劳动' : index == 2 ? '劳动总结报告' : index == 3 ? '社会公益劳动' : '劳动成果'}}</view>
          <view class="fs-24 col888" v-if="index == 1">分类：{{item.type == 1 ? '宿舍/教/实验劳动' : item.type == 2 ? '校内公共区劳动' : item.type == 3 ? '学校服务资源劳动' : item.type == 4 ? '劳动报告心得体会' : item.type == 5 ? '大学生创新创业' : item.type == 6 ? '互联网+报告' : item.type == 7 ? '演讲比赛/知识竞赛' : item.type == 8 ? '劳动执行/文明宿舍' : item.type == 9 ? '公益活动' : item.type == 10 ? '科技帮扶报告' : item.type == 11 ? '劳动周报告' : ''}}</view>
          <view class="fs-24 col888" v-else>分类：{{index == 2 ? '劳动总结报告' : index == 3 ? '社会公益劳动' : '劳动成果'}}</view>
        </view>
        <view class="rowscl" style="align-items: flex-end;">
          <!-- <view class="fs-24 pl-20 pr-20 h-50 br-25 rowsc rowsm mb-14" style="color: #4878FF;border: 2rpx solid #4878FF;">{{item.markNumber && index != 1 ? item.markNumber : item.dfCount && index == 1 ? item.dfCount + '积分' : '已通过'}}</view> -->
            <view class="fs-24 pl-20 pr-20 h-50 br-25 rowsc rowsm mb-14" style="color: #4878FF;border: 2rpx solid #4878FF;" v-if="item.dfCount">{{item.dfCount}} 积分</view>
           <view class="fs-24 pl-20 pr-20 h-50 br-25 rowsc rowsm mb-14" style="color: #4878FF;border: 2rpx solid #4878FF;" v-else>0 积分</view>
          <view class="fs-24 col888">{{item.createTime}}</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        index:0,
        type:0,
        list:[],
         total:0,
        limit: {
          pageNum: 1,
          pageSize: 10
        },
      };
    },
     onReachBottom() {
      if (this.list.length < this.total) {
        this.limit.pageNum++;
        this.getList()
      }
    },
    onPullDownRefresh() {
      this.limit.pageNum = 1
      this.getList()
    },
    onLoad(e) {
      this.index = e.index
      if(e.index == 1) this.type = e.type
      this.getList()
    },
    methods:{
      goNext(item){
        if(this.index == 1) this.$tools.goNext('/pagesCopy/myScore/workDetail?index=0&id=' + item.id)
        if(this.index == 2) this.$tools.goNext('/pagesCopy/myScore/workDetail?index=1&id=' + item.id)
        if(this.index == 3) this.$tools.goNext('/pagesCopy/myScore/workDetail?index=3&id=' + item.id)
        if(this.index == 4) this.$tools.goNext('/pagesCopy/myScore/workDetail?index=2&id=' + item.id)
      },
      getList(){
        if(this.index == 1){
          this.$tools.axiosFromToken('POST','prold/listPass',{type:this.type},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            let {rows} = res
            this.list = rows
            // this.getMax()
          })
          uni.setNavigationBarTitle({
            title:'基础劳动'
          })
        }
        if(this.index == 2){
          this.$tools.axiosFromToken('POST',`proldzj/listPass?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}`,{},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            // let {rows} = res
            // this.list = rows
             this.total = res.total
            if (this.limit.pageNum == 1) {
              this.list = res.rows;
            } else {
              this.list = [...this.list, ...res.rows];
            }
            this.getMax()
          })
          uni.setNavigationBarTitle({
            title:'劳动总结报告'
          })
        }
        if(this.index == 3){
          this.$tools.axiosFromToken('POST',`proldgy/listPass?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}`,{},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            // let {rows} = res
            // this.list = rows
             this.total = res.total
            if (this.limit.pageNum == 1) {
              this.list = res.rows;
            } else {
              this.list = [...this.list, ...res.rows];
            }
            this.getMax()
            uni.setNavigationBarTitle({
              title:'社会公益劳动'
            })
          })
        }
        if(this.index == 4){
          this.$tools.axiosFromToken('POST',`proldcg/listPass?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}`,{},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            // let {rows} = res
            // this.list = rows
             this.total = res.total
            if (this.limit.pageNum == 1) {
              this.list = res.rows;
            } else {
              this.list = [...this.list, ...res.rows];
            }
            this.getMax()
            uni.setNavigationBarTitle({
              title:'劳动成果'
            })
          })
        }
      },
      getMax(){
        let max = this.list[0].dfCount
        this.list.forEach(item => {
          if(item.dfCount > max) max = item.dfCount
        })
        console.log(max)
        this.list.forEach(i => {
          if(i.dfCount == max) i.isMax = true
        })
      }
    }
  }
</script>

<style lang="scss">
page {
  background-color: #fff;
}
</style>
